<%@ page import="assignmentonepenguins.Listing" %>



<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'name', 'error')} ">
    <label for="name">
        <g:message code="listing.name.label" default="Name"/>

    </label>
    <g:textField name="name" maxlength="63" value="${listingInstance?.name}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'description', 'error')} ">
    <label for="description">
        <g:message code="listing.description.label" default="Description"/>

    </label>
    <g:textArea name="description" cols="40" rows="5" maxlength="255" value="${listingInstance?.description}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'winner', 'error')} ">
    <label for="winner">
        <g:message code="listing.winner.label" default="Winner"/>

    </label>
    <g:select id="winner" name="winner.id" from="${assignmentonepenguins.Customer.list()}" optionKey="id"
              optionValue="email" value="${listingInstance?.winner?.id}" class="many-to-one" noSelection="['null': '']"/>
</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'biddings', 'error')} ">
    <label for="biddings">
        <g:message code="listing.biddings.label" default="Biddings"/>

    </label>

    <ul class="one-to-many">
        <g:set var="counter" value="${0}" />
        <g:each in="${listingInstance?.biddings ?}" var="b">
            <g:set var="counter" value="${counter + 1}" />
            <li><g:link controller="bidding" action="show" id="${b.id}">${counter}: ${b?.getBidder()?.getEmail()} - $${b?.getAmount()}</g:link></li>
        </g:each>
        <li class="add">
            <g:link controller="bidding" action="create"
                    params="['listing.id': listingInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'bidding.label', default: 'Bidding')])}</g:link>
        </li>
    </ul>

</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'startBid', 'error')} required">
    <label for="startBid">
        <g:message code="listing.startBid.label" default="Start Bid"/>
        <span class="required-indicator">*</span>
    </label>
    $<g:field type="double" name="startBid" min="0.01" required=""
             value="${fieldValue(bean: listingInstance, field: 'startBid')}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'endDate', 'error')} required">
    <label for="endDate">
        <g:message code="listing.endDate.label" default="End Date"/>
        <span class="required-indicator">*</span>
    </label>
    <g:datePicker name="endDate" precision="day" value="${listingInstance?.endDate}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: listingInstance, field: 'seller', 'error')} required">
    <label for="seller">
        <g:message code="listing.seller.label" default="Seller"/>
        <span class="required-indicator">*</span>
    </label>
    <g:select id="seller" name="seller.id" from="${assignmentonepenguins.Customer.list()}" optionKey="id" required=""
              optionValue="email" value="${listingInstance?.seller?.id}" class="many-to-one"/>
</div>

